using UnityEngine;
using System.Collections;

public class GameInfoDebug : MonoBehaviour {
	
	public float updateInterval = 0.5F;
	private float lastInterval;
	private int frames = 0;
	private float fps;
	
	void Start() {
		DontDestroyOnLoad(gameObject);
		lastInterval = Time.realtimeSinceStartup;
		frames = 0;
	}
	
	void OnGUI() {
		GUI.Label(new Rect(384,0,100,100),"FPS:" + fps.ToString("f2"));
	}
	
	void Update() {
		++frames;
		float timeNow = Time.realtimeSinceStartup;
		if (timeNow > lastInterval + updateInterval) {
			fps = frames / (timeNow - lastInterval);
			frames = 0;
			lastInterval = timeNow;
		}
	}
}
